package com.vvv.designpattern.conf;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author vvv
 * @date 2023-11-24 14 58
 * discription
 */
@Configuration
public class MqConfig {

    @Bean
    public DirectExchange normalExchange() {
        return new DirectExchange("normalExchange");
    }

    @Bean
    public Queue normalQueue() {
        return QueueBuilder.durable("normalQueue")
                .deadLetterExchange("deadExchange")
                .build();
    }

    @Bean
    public FanoutExchange deadExchange() {
        return new FanoutExchange("deadExchange");
    }

    @Bean
    public Queue deadQueue() {
        return new Queue("deadQueue");
    }

    @Bean
    public Binding dlBinding() {
        return BindingBuilder.bind(deadQueue()).to(deadExchange());
    }

    @Bean
    public Binding bindingQueue(Queue normalQueue, DirectExchange normalExchange){
        return BindingBuilder.bind(normalQueue).to(normalExchange).with("myRkey");
    }
}
